﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;

namespace Campus {
    class ComputerScientist : Unit {
        static public List<Texture2D> idleAnim = new List<Texture2D>();
        static public List<Texture2D> walkRightAnim = new List<Texture2D>();
        static public List<Texture2D> walkLeftAnim = new List<Texture2D>();
        static public List<Texture2D> walkUpAnim = new List<Texture2D>();
        static public List<Texture2D> walkDownAnim = new List<Texture2D>();
        static public List<Texture2D> attackRightAnim = new List<Texture2D>();
        static public List<Texture2D> attackLeftAnim = new List<Texture2D>();
        static public List<Texture2D> dieAnim = new List<Texture2D>();

        private void CreateAbilites() {
            Abilities.Add("Move", new MoveAbility(this, Vector2.Zero));
            Abilities.Add("Attack", new MeleeAttack(this, null, Ability.TargetTypes.BaseEntityTarget, 10, 15, 1000));
            Abilities.Add("Hack Resources", new StealResourceAbility(MenuIcons.StealResourcesIcon, this, 30, 30, 100, 1000));
            this.CanAttack = true;
        }

        public ComputerScientist(Vector2 position, Player player, Level level)
            : base(CreateDictionary(), position, 50, player, level, 
            new Dictionary<String, Ability>(), new Dictionary<String, AbilitySubMenu>())
        {
            m_name = "Computer Scientist";
            m_entitySelectedImage = idleAnim[0];
            Size = new Vector2(60, 60);
            CreateAbilites();
        }

        public override void Update(GameTime gameTime, bool checkInput, bool updateBoundingBox)
        {            
            base.Update(gameTime, checkInput, updateBoundingBox);
        }

        static private Dictionary<Unit.UnitState, Animation> CreateDictionary()
        {
            Dictionary<Unit.UnitState, Animation> dict = new Dictionary<UnitState, Animation>();

            // Creates an animation based on the certain static list, then adds it to the
            // Dictionary under the appropriate state.
            dict.Add(UnitState.Idle, new Animation(idleAnim, 100, true));
            
            dict.Add(UnitState.WalkRight, new Animation(walkRightAnim, 75, true));
            dict.Add(UnitState.WalkLeft, new Animation(walkLeftAnim, 75, true));
            dict.Add(UnitState.WalkDown, new Animation(walkDownAnim, 75, true));
            dict.Add(UnitState.WalkUp, new Animation(walkUpAnim, 75, true));
            dict.Add(UnitState.AttackRight, new Animation(attackRightAnim, 70, true));
            dict.Add(UnitState.AttackLeft, new Animation(attackLeftAnim, 70, true));
            dict.Add(UnitState.Die, new Animation(dieAnim, 150, false));

            return dict;
        }


        static public void InitializeAnimations(ContentManager Content)
        {
            // Loads all the idle animation frames
            idleAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistIDLE_0"));
            idleAnim.Add(idleAnim[0]);
            idleAnim.Add(idleAnim[0]);
            idleAnim.Add(idleAnim[0]);
            idleAnim.Add(idleAnim[0]);
            idleAnim.Add(idleAnim[0]);
            idleAnim.Add(idleAnim[0]);
            idleAnim.Add(idleAnim[0]);
            idleAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistIDLE_1"));
            idleAnim.Add(idleAnim[8]);
            idleAnim.Add(idleAnim[8]);
            idleAnim.Add(idleAnim[8]);
            idleAnim.Add(idleAnim[8]);
            idleAnim.Add(idleAnim[8]);
            idleAnim.Add(idleAnim[8]);
            idleAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistIDLE_2"));
            idleAnim.Add(idleAnim[15]);
            idleAnim.Add(idleAnim[15]);
            idleAnim.Add(idleAnim[15]);
            idleAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistIDLE_3"));
            idleAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistIDLE_4"));
            idleAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistIDLE_5"));
            idleAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistIDLE_6"));
            idleAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistIDLE_7"));
            idleAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistIDLE_8"));
            idleAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistIDLE_9"));
            idleAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistIDLE_10"));
            idleAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistIDLE_11"));

            walkRightAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistWALKRIGHT_0"));
            walkRightAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistWALKRIGHT_1"));
            walkRightAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistWALKRIGHT_2"));
            walkRightAnim.Add(walkRightAnim[1]);
            walkRightAnim.Add(walkRightAnim[0]);
            walkRightAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistWALKRIGHT_3"));
            walkRightAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistWALKRIGHT_4"));
            walkRightAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistWALKRIGHT_5"));
            walkRightAnim.Add(walkRightAnim[6]);
            walkRightAnim.Add(walkRightAnim[5]);

            walkLeftAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistWALKLEFT_0"));
            walkLeftAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistWALKLEFT_1"));
            walkLeftAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistWALKLEFT_2"));
            walkLeftAnim.Add(walkLeftAnim[1]);
            walkLeftAnim.Add(walkLeftAnim[0]);
            walkLeftAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistWALKLEFT_3"));
            walkLeftAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistWALKLEFT_4"));
            walkLeftAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistWALKLEFT_5"));
            walkLeftAnim.Add(walkLeftAnim[6]);
            walkLeftAnim.Add(walkLeftAnim[5]);

            walkDownAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistWALKDOWN_0"));
            walkDownAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistWALKDOWN_1"));
            walkDownAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistWALKDOWN_2"));
            walkDownAnim.Add(walkDownAnim[2]);
            walkDownAnim.Add(walkDownAnim[1]);
            walkDownAnim.Add(walkDownAnim[0]);
            walkDownAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistWALKDOWN_3"));
            walkDownAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistWALKDOWN_4"));
            walkDownAnim.Add(walkDownAnim[6]);
            walkDownAnim.Add(walkDownAnim[5]);

            walkUpAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistWALKUP_0"));
            walkUpAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistWALKUP_1"));
            walkUpAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistWALKUP_2"));
            walkUpAnim.Add(walkUpAnim[1]);
            walkUpAnim.Add(walkUpAnim[0]);
            walkUpAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistWALKUP_3"));
            walkUpAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistWALKUP_4"));
            walkUpAnim.Add(walkUpAnim[5]);
            walkUpAnim.Add(walkUpAnim[4]);

            attackRightAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistATTACKRIGHT_2"));
            attackRightAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistATTACKRIGHT_0"));
            attackRightAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistATTACKRIGHT_1"));
            attackRightAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistATTACKRIGHT_5"));
            attackRightAnim.Add(attackRightAnim[0]);
            attackRightAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistATTACKRIGHT_3"));
            attackRightAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistATTACKRIGHT_4"));
            attackRightAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistATTACKRIGHT_6"));

            attackLeftAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistATTACKLEFT_2"));
            attackLeftAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistATTACKLEFT_0"));
            attackLeftAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistATTACKLEFT_1"));
            attackLeftAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistATTACKLEFT_5"));
            attackLeftAnim.Add(attackLeftAnim[0]);
            attackLeftAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistATTACKLEFT_3"));
            attackLeftAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistATTACKLEFT_4"));
            attackLeftAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistATTACKLEFT_6"));

            dieAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistDEATH_0"));
            dieAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistDEATH_1"));
            dieAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistDEATH_2"));
            dieAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistDEATH_3"));
            dieAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistDEATH_4"));
            dieAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistDEATH_5"));
            dieAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistDEATH_6"));
            dieAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistDEATH_7"));
            dieAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistDEATH_8"));
            dieAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistDEATH_9"));
            dieAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistDEATH_10"));
            dieAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistDEATH_11"));
            dieAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistDEATH_12"));
            dieAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistDEATH_13"));
            dieAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistDEATH_14"));
            dieAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistDEATH_15"));
            dieAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistDEATH_16"));
            dieAnim.Add(Content.Load<Texture2D>("Units/Computer Scientist/computerScientistDEATH_17"));
        }
    }
}
